<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>首页</title>
    <jsp:include page="../../include/resource.jsp"/>
</head>
<body>
<jsp:include page="../../include/header.jsp"/>
<div class="container">
    <div class="table-responsive">
        <table class="table">
            <thead>
            <tr>
                <th>课程名</th>
                <th>教练名</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>状态</th>
                <th>审核意见</th>
                <th>描述</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${list}" var="item">
                <tr class="">
                    <td>${item.name}</td>
                    <td>${item.teacher}</td>
                    <td>${item.starttime} </td>
                    <td>${item.endtime} </td>
                    <td>${item.status} </td>
                    <td>${item.verify} </td>
                    <td>${item.descript}</td>
                    <td>
                        <a href="/member/course/del/${item.id}.do" class="btn btn-xs btn-danger">删除</a>
                        <a href="/member/course/detail/${item.id}.do" class="btn btn-xs btn-success">详情</a>
                        <c:if test="${sessionUser.type == 'admin' && item.status == '待审核'}">
                            <a href="#" onclick="verify('${item.id}')" class="btn btn-xs btn-primary">审核</a>
                        </c:if>
                        <c:if test="${sessionUser.type == 'jl'}">
                            <a href="#" onclick="upload('${item.id}')" class="btn btn-xs btn-primary">上传课件</a>
                        </c:if>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>


<div id="modal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">上传附件</h4>
            </div>
            <div class="modal-body">
                <form name="form" id="uploadform" class="form-horizontal" enctype="multipart/form-data"
                      method="post" action="/member/course/upload.do">
                    <input id="id" type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-7 control-label">选择附件（会覆盖以前的，请一起打包上传）</label>
                        <div class="col-sm-5">
                            <input type="file" required class="form-control" name="file">
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" form="uploadform" class="btn btn-primary">修改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->



<div id="ver" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">审核课程</h4>
            </div>
            <div class="modal-body">
                <form id="v" name="form" class="form-horizontal" method="post" action="/member/course/update.do">
                    <input id="verid" type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">审核结果</label>
                        <div class="col-sm-5">
                            <input type="radio" required  name="status" checked value="通过">通过
                            <input type="radio" required  name="status" value="不通过">不通过
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">审核意见</label>
                        <div class="col-sm-5">
                            <input type="text" required class="form-control" name="verify">
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" form="v" class="btn btn-primary">修改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
    function upload(id) {
        $("#id").val(id);
        $("#modal").modal("show");
    }

    function verify(id) {
        $("#verid").val(id);
        $("#ver").modal("show");
    }

</script>
</body>
</html>
